package TestFinal;

import org.junit.Assert;
import org.junit.Test;

public class Main {
    private final InventorySystem inventorySystem = new InventorySystem();
    private final Inventory inventory = new Inventory();
    @Test
    public void testChoose1() {
        inventorySystem.choose1();
    }

    @Test
    public void findProductByNameTest() {
        String str = inventory.findProductByName("aa");
        System.out.println(str);
        String trueStr = "商品名称：aa\n" +
                "价格：2.33\n" +
                "库存数量：10\n" +
                "============\n";
        System.out.println(trueStr);
        Assert.assertEquals("Error", trueStr, str);
    }

    @Test
    public void findProductByErrorName() {
        String str = inventory.findProductByName("aaa");
        String trueStr = "商品不存在";
        Assert.assertEquals("Error", trueStr, str);
    }

    @Test
    public void subNullProduct() {

        RuntimeException exception = Assert.assertThrows(RuntimeException.class, () -> {
            inventory.subtractProductQuantity(new Product("zzz", 15, 56));
        });
        Assert.assertEquals("商品不存在", exception.getMessage());
    }

    public static void main(String[] args) {
        InventorySystem si = new InventorySystem();
        si.start();
    }
}


